package auction.chapter12;

import java.sql.Connection;

import org.hibernate.Session;

import persistence.HibernateUtil;
import auction.chapter12.model.AuditLogRecord;

public class AuditLog {
	public static void logEvent(String message,Auditable entity,Long userId,Connection con){
		Session tmps=HibernateUtil.getSessionFactory().openSession(con);
		
		try{
			AuditLogRecord domain=new AuditLogRecord(message,entity.getId(),entity.getClass(),userId);
			tmps.save(domain);
			tmps.flush();
		}finally{
			tmps.close();
		}
	}
}
